import cgi;
import urllib;

print "Content-Type: text/plain\n"

try:
    form = cgi.FieldStorage()
    filepath = urllib.unquote(form.getvalue("filepath"))
    formvalue = form.getvalue("genes")
    genes = []
    if formvalue is not None: genes = formvalue.split(",")

    rfile = open(filepath)
    for idx, line in enumerate(rfile):
        if idx == 0:
            print line.rstrip()
        else:
            for gene in genes:
                if line.startswith(gene):
                    print line.rstrip()
                    break
except Exception,e:
    print str(e) + "\n"
